// import type { UserConfig } from 'vite'
import { defineConfig } from "vite";
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression'

const webpack = require('webpack')

import path from "path"

// import { resolve } from 'path';
// function pathResolve(dir: string) {
//   return resolve(__dirname, '.', dir);
// }
// const alias: Record<string, string> = {
//   "@": path.resolve(__dirname,'src')
//   //"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js", //解决警告You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
// };
// console.log(process)
// const viteConfig: UserConfig = {
export default defineConfig({
  define: {
    'process.env': {}
  },
  plugins: [
    vue(),
    viteCompression({
      verbose: true,
      disable: false,
      threshold: 10240,
      algorithm: 'gzip',
      ext: '.gz'
    }),
    new webpack.ProvidePlugin({
      $:"jquery",
      jQuery:"jquery",
      "windows.jQuery":"jquery"
    })
  ],
  base: "./",
  // server: {
  //   host: '0.0.0.0',
  //   port: 3000,
  //   open: false,
  //   https: false,
  //   proxy: {}
  // },
  resolve: {
    alias: {
      // 如果报错__dirname找不到，需要安装node,执行yarn add @types/node --save-dev
      "@": path.resolve(__dirname, "src"),
      "comps": path.resolve(__dirname, "src/components"),
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData:
          '@import "./src/assets/css/hack.scss";'
      }
    }
  }
})
// export default viteConfig;
